package pyip.lib.javalearn.thread.exit;

public class MainSubLifeCycleDemo implements Runnable {

    public void run() {
        for (int i = 0; i < 100; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String threadName = Thread.currentThread().getName();
            System.out.println("\t" + threadName + " is running");
        }
    }

    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName() + " is start");

        Thread t1 = new Thread(new MainSubLifeCycleDemo(), "t1");
        Thread t2 = new Thread(new MainSubLifeCycleDemo(), "t2");

//        t1.setDaemon(true);
//        t2.setDaemon(true);
        t1.start();
        t2.start();

        System.out.println(Thread.currentThread().getName() + " exit");
    }
}